<?php
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $fecha1 = $_REQUEST['capass2'];
    $fecha2 = $_REQUEST['capass22'];
    
    $f1 = date('Y-m-d',strtotime($fecha1));
    $f2 = date('Y-m-d',strtotime($fecha2));
    
    $indi = "select case when adm_admi = 'si' then 'Pacientes recibidos en Urgencias' end as pacReciu, adm.cantidad
            from admisionUG as admi
            outer apply(select COUNT(DISTINCT adm_docPac) as cantidad 
                                    from admisionUG 
                                    where  adm_fecha between '".$f1."' and '".$f2."'and adm_admi = 'si')as adm
            where adm_admi ='si' 
            group by adm_admi,adm.cantidad
            union
            select case when adm_admi = 'no' then 'Pacientes no Recibidos en Urgencias' end as pacReciu, adm.cantidad
            from admisionUG as admi
            outer apply(select COUNT(DISTINCT adm_docPac) as cantidad 
                                    from admisionUG 
                                    where  adm_fecha between '".$f1."' and '".$f2."'and adm_admi = 'no')as adm
            where adm_admi ='no' 
            group by adm_admi,adm.cantidad
            union
            select case when adm_admi = '' then 'Sin Respuesta' end as pacReciu, adm.cantidad
            from admisionUG as admi
            outer apply(select COUNT(DISTINCT adm_docPac) as cantidad 
                                    from admisionUG 
                                    where  adm_fecha between '".$f1."' and '".$f2."'and adm_admi = '')as adm
            where adm_admi ='' 
            group by adm_admi,adm.cantidad ";
    $lsti = $con->query($indi);
    while($res = mssql_fetch_array($lsti)){
        $lst[] = $res;
    }
    $con->cerrarConexion();
    print_r(json_encode($lst));

?>